package com.shuqi.model;

import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import android.content.Context;

import com.shuqi.common.MyTask;
import com.shuqi.common.Urls;
import com.shuqi.model.net.HttpRequest;
import com.shuqi.model.net.UrlManager;
import com.shuqi.model.net.listener.HttpRequestListener;
import com.shuqi.model.parse.parser.OfferWallOpenParser;

public class OfferWallOpenModel extends ModelBase implements HttpRequestListener {
    private HttpRequest httpRequest;
    private Context context;

    public OfferWallOpenModel(Context context) {
        this.context = context;
    }

    @Override
    public void action(int actionCode, Object object) {
        fireEvent(actionCode, object);
    }

    @Override
    public List<BasicNameValuePair> setParams() {
        return null;
    }

    @Override
    public String getRequestUrl() {
        return Urls.getOfferWallOpenUrl(context);
    }

    @Override
    public void loadData(Object... objs) {
        this.httpRequest = new HttpRequest(context, getRequestUrl(), false, this);
        this.httpRequest.setDataParseAdapter(new OfferWallOpenParser());
        MyTask.runInBackground(httpRequest, true);
    }

    @Override
    public void onDestroy() {
        if (httpRequest != null) {
            httpRequest.abort();
        }
    }

}
